import sys
from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QLabel, QLineEdit, QPushButton, QWidget, QComboBox
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import  pyqtSignal
from .c_lineEdit import LineEditFloat

class FixedWidget(QWidget):
    fixed_coordinates_signal = pyqtSignal(object)
    
    def __init__(self, parent=None):
        super(FixedWidget, self).__init__(parent)
        
        hLayout = QHBoxLayout()
        vLayout = QVBoxLayout()
        hLayout_point1 = QHBoxLayout()
        hLayout_point2 = QHBoxLayout()
        
        label1 = QLabel("坐标点1")
        self.lineE1_x = LineEditFloat()
        self.lineE1_y = LineEditFloat()
        self.lineE1_z = LineEditFloat()
 
        button1 = QPushButton()
        button1.setIcon(QIcon('./icons/mouse_click.png'))  # 替换为你的图片路径
        button1.clicked.connect(self.on_button1_clicked)
        hLayout_point1.addWidget(label1)
        hLayout_point1.addWidget(self.lineE1_x)
        hLayout_point1.addWidget(self.lineE1_y)
        hLayout_point1.addWidget(self.lineE1_z)
        hLayout_point1.addWidget(button1)
        
        label2 = QLabel("坐标点2")
        self.lineE2_x = LineEditFloat()
        self.lineE2_y = LineEditFloat()
        self.lineE2_z = LineEditFloat()
        button2 = QPushButton()
        button2.setIcon(QIcon('./icons/mouse_click.png'))  # 替换为你的图片路径
        button2.clicked.connect(self.on_button2_clicked)
        hLayout_point2.addWidget(label2)
        hLayout_point2.addWidget(self.lineE2_x)
        hLayout_point2.addWidget(self.lineE2_y)
        hLayout_point2.addWidget(self.lineE2_z)
        hLayout_point2.addWidget(button2)
        
        vLayout.addLayout(hLayout_point1)
        vLayout.addLayout(hLayout_point2)
        
        title_layout = QVBoxLayout()
        label_title1 = QLabel("线段 ")
        label_title2 = QLabel(" ")
        title_layout.addWidget(label_title1)
        title_layout.addWidget(label_title2)
        
        hLayout.addLayout(title_layout)
        hLayout.addLayout(vLayout)
        self.setLayout(hLayout)
    
    def on_button1_clicked(self):
        self.fixed_coordinates_signal.emit("1")
    def on_button2_clicked(self):
        self.fixed_coordinates_signal.emit("2")

class ParamsWidget(QWidget):
    parametric_coordinates_signal = pyqtSignal(object)
    
    def __init__(self, parent=None):
        super(ParamsWidget, self).__init__(parent)
        
        layout = QVBoxLayout()
        hLayout = QHBoxLayout()
        vLayout = QVBoxLayout()
        hLayout_params = QHBoxLayout()
        hLayout_point1_1 = QHBoxLayout()
        hLayout_point1_2 = QHBoxLayout()
        hLayout_point2_1 = QHBoxLayout()
        hLayout_point2_2 = QHBoxLayout()
        
        label_params = QLabel("布局参数")
        self.line_params = LineEditFloat()
        hLayout_params.addWidget(label_params)
        hLayout_params.addWidget(self.line_params)
        
        label_line1_1 = QLabel("坐标点1")
        self.lineX1_1 = LineEditFloat()
        self.lineY1_1 = LineEditFloat()
        self.lineZ1_1 = LineEditFloat()
        btn1_1 = QPushButton()
        btn1_1.setIcon(QIcon('./icons/mouse_click.png'))  # 替换为你的图片路径
        btn1_1.clicked.connect(self.on_btn1_1_clicked)
        hLayout_point1_1.addWidget(label_line1_1)
        hLayout_point1_1.addWidget(self.lineX1_1)
        hLayout_point1_1.addWidget(self.lineY1_1)
        hLayout_point1_1.addWidget(self.lineZ1_1)
        hLayout_point1_1.addWidget(btn1_1)
        
        label_line1_2 = QLabel("坐标点2")
        self.lineX1_2 = LineEditFloat()
        self.lineY1_2 = LineEditFloat()
        self.lineZ1_2 = LineEditFloat()
        btn1_2 = QPushButton()
        btn1_2.setIcon(QIcon('./icons/mouse_click.png'))  # 替换为你的图片路径
        btn1_2.clicked.connect(self.on_btn1_2_clicked)
        hLayout_point1_2.addWidget(label_line1_2)
        hLayout_point1_2.addWidget(self.lineX1_2)
        hLayout_point1_2.addWidget(self.lineY1_2)
        hLayout_point1_2.addWidget(self.lineZ1_2)
        hLayout_point1_2.addWidget(btn1_2)
        
        label_line2_1 = QLabel("坐标点1")
        self.lineX2_1 = LineEditFloat()
        self.lineY2_1 = LineEditFloat()
        self.lineZ2_1 = LineEditFloat()
        btn2_1 = QPushButton()
        btn2_1.setIcon(QIcon('./icons/mouse_click.png'))  # 替换为你的图片路径
        btn2_1.clicked.connect(self.on_btn2_1_clicked)
        hLayout_point2_1.addWidget(label_line2_1)
        hLayout_point2_1.addWidget(self.lineX2_1)
        hLayout_point2_1.addWidget(self.lineY2_1)
        hLayout_point2_1.addWidget(self.lineZ2_1)
        hLayout_point2_1.addWidget(btn2_1)
        
        label_line2_2 = QLabel("坐标点2")
        self.lineX2_2 = LineEditFloat()
        self.lineY2_2 = LineEditFloat()
        self.lineZ2_2 = LineEditFloat()
        btn2_2 = QPushButton()
        btn2_2.setIcon(QIcon('./icons/mouse_click.png'))  # 替换为你的图片路径
        btn2_2.clicked.connect(self.on_btn2_2_clicked)
        hLayout_point2_2.addWidget(label_line2_2)
        hLayout_point2_2.addWidget(self.lineX2_2)
        hLayout_point2_2.addWidget(self.lineY2_2)
        hLayout_point2_2.addWidget(self.lineZ2_2)
        hLayout_point2_2.addWidget(btn2_2)
        
        vLayout.addLayout(hLayout_point1_1)
        vLayout.addLayout(hLayout_point1_2)
        vLayout.addLayout(hLayout_point2_1)
        vLayout.addLayout(hLayout_point2_2)
        
        title_layout = QVBoxLayout()
        label_title1 = QLabel("线段 ")
        label_title2 = QLabel(" ")
        label_title3 = QLabel("线段 ")
        label_title4 = QLabel(" ")
        title_layout.addWidget(label_title1)
        title_layout.addWidget(label_title2)
        title_layout.addWidget(label_title3)
        title_layout.addWidget(label_title4)
        
        hLayout.addLayout(title_layout)
        hLayout.addLayout(vLayout)
        layout.addLayout(hLayout_params)
        layout.addLayout(hLayout)
        self.setLayout(layout)
        
    def on_btn1_1_clicked(self):
        self.parametric_coordinates_signal.emit("1_1")
    def on_btn1_2_clicked(self):
        self.parametric_coordinates_signal.emit("1_2")
    def on_btn2_1_clicked(self):
        self.parametric_coordinates_signal.emit("2_1")
    def on_btn2_2_clicked(self):
        self.parametric_coordinates_signal.emit("2_2")
        
class ParamsBoundaryWidget(QWidget):
    parametricRegion_coordinates_signal = pyqtSignal(object)
    
    def __init__(self, parent=None):
        super(ParamsBoundaryWidget, self).__init__(parent)
        
        layout = QVBoxLayout()
        hLayout = QHBoxLayout()
        vLayout = QVBoxLayout()
        hLayout_point1 = QHBoxLayout()
        hLayout_point2 = QHBoxLayout()
        hLayout_scope = QHBoxLayout()
        
        label_scope = QLabel("区域范围")
        self.comboBox_scope = QComboBox()
        self.comboBox_scope.setMinimumWidth(100)
        hLayout_scope.addWidget(label_scope)
        hLayout_scope.addWidget(self.comboBox_scope)
        hLayout_scope.addStretch(1)
        
        label1 = QLabel("坐标点1")
        self.lineE1_x = LineEditFloat()
        self.lineE1_y = LineEditFloat()
        self.lineE1_z = LineEditFloat()
        # 创建一个QPushButton
        button1 = QPushButton()
        button1.setIcon(QIcon('icons/mouse_click.png'))  # 替换为你的图片路径
        button1.clicked.connect(self.on_button1_clicked)
        hLayout_point1.addWidget(label1)
        hLayout_point1.addWidget(self.lineE1_x)
        hLayout_point1.addWidget(self.lineE1_y)
        hLayout_point1.addWidget(self.lineE1_z)
        hLayout_point1.addWidget(button1)
        
        label2 = QLabel("坐标点2")
        self.lineE2_x = LineEditFloat()
        self.lineE2_y = LineEditFloat()
        self.lineE2_z = LineEditFloat()
        button2 = QPushButton()
        button2.setIcon(QIcon('icons/mouse_click.png'))  # 替换为你的图片路径
        button2.clicked.connect(self.on_button2_clicked)
        hLayout_point2.addWidget(label2)
        hLayout_point2.addWidget(self.lineE2_x)
        hLayout_point2.addWidget(self.lineE2_y)
        hLayout_point2.addWidget(self.lineE2_z)
        hLayout_point2.addWidget(button2)
        
        vLayout.addLayout(hLayout_point1)
        vLayout.addLayout(hLayout_point2)
        
        title_layout = QVBoxLayout()
        label_title1 = QLabel("线段 ")
        label_title2 = QLabel(" ")
        title_layout.addWidget(label_title1)
        title_layout.addWidget(label_title2)
        
        hLayout.addLayout(title_layout)
        hLayout.addLayout(vLayout)
        layout.addLayout(hLayout_scope)
        layout.addLayout(hLayout)
        self.setLayout(layout)
        
    def on_button1_clicked(self):
        self.parametricRegion_coordinates_signal.emit("1")
    def on_button2_clicked(self):
        self.parametricRegion_coordinates_signal.emit("2")
        

